<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="dwz" uri="http://www.lyjuan.cn/dwz/tags" %>

<div class="pageContent">
    <form method="post" action="<dwz:url url="action/addAction"/>" class="pageForm"
          onsubmit="return validateCallback(this, customDialogAjaxDone(true, 'action_actionList'));">
        <div class="pageFormContent" layoutH="58">
            <p>
                <label>名称：</label>
                <input type="text" name="name" class="required" style="width:200px;" tabindex="1"/>
            </p>
            <p>
                <label>地址：</label>
                <input type="text" id="actionurl" name="actionurl" class="required" placeholder="不带后缀"
                       onkeyup="genRelByUrl(this.value);" tabindex="2"/>
            </p>

            <p>
                <label>所属组：</label>
                <input type="hidden" name="groupid" btnBackName="selectGroup.groupid" value="${group.id}"/>
                <input type="text" name="groupname" btnBackName="selectGroup.groupname" value="${group.name}" tabindex="3" readonly/>
                <a class="btnLook" href="<dwz:url url="group/selectGroup"/>" lookupgroup="selectGroup" lookuppk="selectGroup">选择组</a>
            </p>
            <p>
                <label>显示方式：</label>
                <input type="radio" name="target" value="navTab" checked="checked" id="target_navTab" onclick="showNav();"/>
                <span onclick="$(this).parents('form:first').find('#target_navTab').click();">标签页</span>&nbsp;&nbsp;
                <input type="radio" name="target" value="dialog" id="target_dialog" onclick="hideNav();"/>
                <span onclick="$(this).parents('form:first').find('#target_dialog').click();">弹窗</span>&nbsp;&nbsp;
                <input type="radio" name="target" value="ajax" id="target_ajax" onclick="hideNav();"/>
                <span onclick="$(this).parents('form:first').find('#target_ajax').click();">AJAX</span>
            </p>
            <p id="isnavUnit">
                <label>是否导航显示：</label>
                <input type="radio" name="isnav" value="1" id="isnav_show" checked="checked"/>
                <span onclick="$(this).parents('form:first').find('#isnav_show').click();">导航</span>&nbsp;&nbsp;
                <input type="radio" name="isnav" value="0" id="isnav_hide" />
                <span onclick="$(this).parents('form:first').find('#isnav_hide').click();">非导航</span>
            </p>
            <p id="relUnit">
                <label>标签标识：</label>
                <input type="text" name="rel" id="rel"/>
            </p>
            <p id="sortUnit">
                <label>排序：</label>
                <input type="text" name="sort" value="100" class="required"/>
            </p>
            <p>
                <label>状态：</label>
                <input type="radio" name="status" value="1" id="status_normal" checked="checked"/>
                <span onclick="$(this).parents('form:first').find('#status_normal').click();">正常</span>&nbsp;&nbsp;
                <input type="radio" name="status" value="0" id="status_lock"/>
                <span onclick="$(this).parents('form:first').find('#status_lock').click();">锁定</span>
            </p>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">提交</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">取消</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>

</div>

<script>
    var form = $('form[action="<dwz:url url="action/addAction"/>"]');
    /**
     * 根据请求 action 地址生成标识
     */
    var genRelByUrl = function (url) {
        //if (!url) return true;
        if (url)
            url = url.replace(/\//g, '_');

        form.find('#rel').val(url);
    };

    /**
     * 显示导航属性
     */
    var showNav = function () {
        form.find('#isnavUnit').show();
        form.find('#isnavUnit input:first').attr("checked", "checked");
        genRelByUrl(form.find('#actionurl').val());
        form.find('#sortUnit').show();
    };

    /**
     * 隐藏导航属性
     */
    var hideNav = function () {
        form.find('#isnavUnit').hide();
        form.find('#isnavUnit input').removeAttr('checked');

        form.find('#sortUnit').hide();
    };
</script>